<?php

declare (strict_types = 1);

namespace app\api\controller\v1;

use app\common\controller\BaseController;
use app\common\service\PayService;
use think\Request;

class Pay extends BaseController
{
    protected Request $request;

    public function __construct(PayService $payService, Request $request)
    {
        $this->service = $payService;
        $this->request = $request;
    }

    /**
     * 收银台
     *
     * @return \think\Response
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function checkout(): \think\Response
    {
        $params = $this->getParams();
        return $this->success($this->service->checkout($params['order_id']));
    }

    /**
     * 支付
     *
     * @return \think\Response
     */
    public function doPay(): \think\Response
    {
        $params = $this->getParams();
        return $this->success($this->service->createOrder($params['order_id'], $params['payment_method']));
    }

    /**
     * 获取所有支付方式
     *
     * @return \think\Response
     */
    public function getPaymentMethods(): \think\Response
    {

    }
}